# 数组定义
bicycles = ['trek', 'cannondale', 'redline', 'specialized']
print(bicycles)

print(bicycles[0])
print(bicycles[1])

# 最后一个
print(bicycles[-1])

# 添加元素
bicycles.append("honda")
print(bicycles)

motorcycles = []
motorcycles.append('honda')
motorcycles.append('yamaha')
motorcycles.append('suzuki')

print(motorcycles)

# 插入元素
motorcycles.insert(0, "111")
print(motorcycles)

# 根据index删除元素
del motorcycles[0]
print(motorcycles)

# 取出并删除
# result = motorcycles.pop()
result = motorcycles.pop(0)
print(result)
print(motorcycles)

# 根据value删除
motorcycles.remove("suzuki")
print(motorcycles)

# 排序
cars = ['bmw', 'audi', 'toyota', 'subaru']
# sorted方法临时排序 不会改变源数组的顺序
print(sorted(cars))
print(cars)

# sort方法会改变源数组的顺序
cars.sort()
print(cars)

cars.sort(reverse=True)
print(cars)


cars.reverse()
print(cars)

# 长度
print(len(cars))